﻿<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<script src="${pageContext.request.contextPath}/js/jquery-2.1.4.min.js"></script>
<script src="${pageContext.request.contextPath}/js/jquery.cookie.js"></script>

<script>
    $(function () {
        //链接处理
        $("#profile-avatar").attr("src", $.cookie('avatar_url'));
        $("#profile-username").text($.cookie('name'));
        if ($.cookie('role') > 1) {
            $("#backdoor").css("display", "none");
        }

        //下拉菜单处理
        var profile = $(".nav-profile");
        var downMenu = $(".nav-dropdown");

        profile.mouseover(function(){
            downMenu.show();
        }).mouseout(function(){
            downMenu.hide();
        });

        downMenu.mouseover(function(){
            downMenu.show();
        }).mouseout(function(){
            downMenu.hide();
        });


        //对找不到图片的<img>标签进行处理
        $("img").error(function () {
            this.src = "/image/404.png";
            this.onerror=null;
        })


    });


    function logout() {
        $.cookie('id', '', { expires: -1, path:'/' });
        $.cookie('name', '', { expires: -1, path:'/' });
        $.cookie('role', '', { expires: -1, path:'/' });
        $.cookie('email', '', { expires: -1, path:'/' });
        $.cookie('avatar_url', '', { expires: -1, path:'/' });
        $.cookie('sim_desc', '', { expires: -1, path:'/' });
        window.location.href="${pageContext.request.contextPath}/login";
    }

</script>


<div class="nav">
    <div class="nav-wrap">
        <a href="${pageContext.request.contextPath}/index"><img class="logo" src="${pageContext.request.contextPath}/image/logo_w.png"></a>
        <a href="${pageContext.request.contextPath}/index" class="title">律援助社区</a>

        <div class="top-nav">
            <ul>
                <li><a href="${pageContext.request.contextPath}/topic/index">板块</a></li>
                <li><a href="${pageContext.request.contextPath}/ques/hot/1">热门</a></li>
                <li><a href="${pageContext.request.contextPath}/ques/lately/1">回答</a></li>
                <li><a href="${pageContext.request.contextPath}/user/message/1">消息</a></li>
            </ul>
            <!-- <div class="notice"></div> -->
        </div>

        <div class="nav-profile">
            <a id="profile-link" class="profile-link">
                <img id="profile-avatar" src="">
                <span id="profile-username"></span>
            </a>
            <ul class="nav-dropdown">
                <li><a href="javascript:showUserMask($.cookie('id'));" class="profile-link"><i class="sprite-nav-profile"></i>&nbsp;&nbsp;&nbsp;我的主页</a>
                </li>
                <li id="backdoor"><a href="${pageContext.request.contextPath}/backdoor/"><i
                        class="sprite-nav-letter"></i>&nbsp;&nbsp;&nbsp;后台管理</a></li>
                <li><a href="${pageContext.request.contextPath}/user/setting"><i class="sprite-nav-setting"></i>&nbsp;&nbsp;&nbsp;设置</a></li>
                <li><a href="javascript:logout();"><i class="sprite-nav-logout"></i>&nbsp;&nbsp;&nbsp;安全退出</a></li>
            </ul>
        </div>
        <div class="search-area">
            <form action="${pageContext.request.contextPath}/ques/search/1">
                <input name="keyWord" type="text" class="search-input" placeholder="搜索...">
                <button type="submit" class="search-button"><i class="sprite-search"></i></button>
            </form>
        </div>
        <button class="ask-question" onclick="showAskMask();">提问</button>

    </div>
</div>
